package com.huilian.iotbox.data.enums;

import lombok.Getter;

import java.util.stream.Stream;

/**
 * mqtt回复处理码
 *
 * @author chenqiwen
 * @CreateDate: 2022-05-12-11-20
 * @Description:
 */
@Getter
public enum MqttReplyQueryResultCodeEnum {
    SUCCESS("10000", 1, "操作成功"),
    FAIL("10001", 0, "操作不成功，请重试"),
    NO_REPLY("10002", -1, "等待终端设备回复"),
    AN_UNKNOWN_FAILURE("10003", 2, "未知失败"),
    UNIFY_CUSTOM_RESULTS("10004", 3, "统一自定义结果"),
    ;

    private String code;
    private Integer resultCode;
    private String desc;

    MqttReplyQueryResultCodeEnum(String code, Integer resultCode, String desc) {
        this.code = code;
        this.resultCode = resultCode;
        this.desc = desc;
    }
    public static MqttReplyQueryResultCodeEnum getCode(Integer value) {
        return Stream.of(MqttReplyQueryResultCodeEnum.values())
                .filter(p -> p.getResultCode() == value)
                .findAny()
                .orElse(null);
    }
}
